package com.yxk.bootvueshop.config;

import com.yxk.bootvueshop.common.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 */
@ControllerAdvice
@ResponseBody
public class MyExceptionHandler {

    @ExceptionHandler(value = ServiceException.class)
    public CommonResult exceptionHandler(ServiceException e) {
        return new CommonResult(null,e.getMessage(),e.getStatus());
    }

}
